package com.becca.cake.model.goods;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import org.springframework.format.annotation.DateTimeFormat;

import com.becca.cake.core.exception.ServiceException;

/**
 * 商品推荐实体
 * @copyright  尊星(上海)信息科技有限公司
 * @author hejinguo
 * @date 2016年4月10日 上午2:47:11
 */
public class GoodsRecommendModel implements Serializable {
    /**  */
    private static final long serialVersionUID        = 4545493092553689139L;
    /**状态(0:推荐))*/
    public static final Byte   RECOMMENT_STATUS_YES    = 0;
    /**状态(1:不推荐))*/
    public static final Byte   RECOMMENT_STATUS_NO    = 1;
    
    /**是否热门(0:否))*/
    public static final Byte   RECOMMENT_ISHOT_NO    = 0;
    /**是否热门(1:是))*/
    public static final Byte   RECOMMENT_ISHOT_YES = 1;
    
    /**推荐类型(0:首页推荐)*/
    public static final Byte  RECOMMENT_TYPE_HOME     = 0;
    /**推荐类型(1:我的生日)*/
    public static final Byte  RECOMMENT_TYPE_BIRTHDAY = 1;
    /**添加上商品对象为空*/
    public static final String  GOODS_RECOMMENT_NULL = "推荐的商品对象为空";
    /**添加的推荐商品已存在*/
    public static final String  RECOMMENT_GOODS_EXIST = "添加的推荐商品已存在";
    /**未修改排序数据*/
    public static final String  RECOMMENT_ORDER_NOT_UPDATE = "未修改排序数据";
    /**商品推荐信息不能为空*/
    public static final String  RECOMMENT_NULL = "商品推荐信息不能为空";
    /**商品推荐类型不能为空*/
    public static final String  RECOMMENT_TYPE_NULL = "商品推荐类型不能为空";
    /**商品推荐开始时间不能为空*/
    public static final String  RECOMMENT_START_DATE_NULL = "商品推荐开始时间不能为空";
    /**商品推荐结束时间不能为空*/
    public static final String  RECOMMENT_END_DATE_NULL = "商品推荐结束时间不能为空";
    
    /**商品推荐排序不能为空*/
    public static final String  RECOMMENT_ORDER_NULL = "商品推荐排序不能为空";

    private Integer           id;

    private Integer           goodsId;
    /**开始时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date              startDate;
    /**结束时间*/
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date              endDate;
    /**是否热门(0:否 1:是)*/
    private Byte              isHot;
    /**推荐类型(0:首页推荐 1：我的生日)*/
    private Byte              recommendType;
    /**状态(0:推荐 1:不推荐))*/
    private Byte              recommendStatus;
    /**排序*/
    private Integer           recommendOrder;
    /**创建时间*/
    private Date              createdDate;
    /**创建人*/
    private String            createdName;
    /**修改时间*/
    private Date              updatedDate;
    /**修改人*/
    private String            updatedName;

    /*****************************************************/
    /**商品名称*/
    private String            goodsName;
    /**商品展示图*/
    private String            goodsPic;
    /**商品默认显示单价*/
    private Double            goodsDefalutPrice;
    
    /**
     * 校验添加商品推荐
     * @param goodsRecommendModel
     */
    public static void validInsertGoodsRecommend(GoodsRecommendModel goodsRecommendModel){
        if(goodsRecommendModel == null){
            throw new ServiceException(GoodsRecommendModel.RECOMMENT_NULL);
        }
        if(goodsRecommendModel.getGoodsId() == null){
            throw new ServiceException(GoodsRecommendModel.GOODS_RECOMMENT_NULL);
        }
        if(goodsRecommendModel.getRecommendType() == null){
            throw new ServiceException(GoodsRecommendModel.RECOMMENT_TYPE_NULL);
        }
        if(goodsRecommendModel.getStartDate() == null){
            throw new ServiceException(GoodsRecommendModel.RECOMMENT_START_DATE_NULL);
        }
        if(goodsRecommendModel.getEndDate() == null){
            throw new ServiceException(GoodsRecommendModel.RECOMMENT_END_DATE_NULL);
        }
        if(goodsRecommendModel.getRecommendOrder() == null){
            throw new ServiceException(GoodsRecommendModel.RECOMMENT_ORDER_NULL);
        }
    }
    
    /**
     * 校验商品推荐排序
     * @param list
     */
    public static void validRecommendOrders(List<GoodsRecommendModel> list){
        for (GoodsRecommendModel goodsRecommendModel : list) {
            if(goodsRecommendModel.getRecommendOrder() == null){
                throw new ServiceException(GoodsRecommendModel.RECOMMENT_ORDER_NULL);
            }
        }
    }
    
    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Date getStartDate() {
        return startDate;
    }

    public void setStartDate(Date startDate) {
        this.startDate = startDate;
    }

    public Date getEndDate() {
        return endDate;
    }

    public void setEndDate(Date endDate) {
        this.endDate = endDate;
    }

    public Byte getRecommendStatus() {
        return recommendStatus;
    }

    public void setRecommendStatus(Byte recommendStatus) {
        this.recommendStatus = recommendStatus;
    }

    public Integer getRecommendOrder() {
        return recommendOrder;
    }

    public void setRecommendOrder(Integer recommendOrder) {
        this.recommendOrder = recommendOrder;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public String getCreatedName() {
        return createdName;
    }

    public void setCreatedName(String createdName) {
        this.createdName = createdName;
    }

    public Date getUpdatedDate() {
        return updatedDate;
    }

    public void setUpdatedDate(Date updatedDate) {
        this.updatedDate = updatedDate;
    }

    public String getUpdatedName() {
        return updatedName;
    }

    public void setUpdatedName(String updatedName) {
        this.updatedName = updatedName;
    }

    public Integer getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(Integer goodsId) {
        this.goodsId = goodsId;
    }

    public Byte getIsHot() {
        return isHot;
    }

    public void setIsHot(Byte isHot) {
        this.isHot = isHot;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsPic() {
        return goodsPic;
    }

    public void setGoodsPic(String goodsPic) {
        this.goodsPic = goodsPic;
    }

    public Double getGoodsDefalutPrice() {
        return goodsDefalutPrice;
    }

    public void setGoodsDefalutPrice(Double goodsDefalutPrice) {
        this.goodsDefalutPrice = goodsDefalutPrice;
    }

    public Byte getRecommendType() {
        return recommendType;
    }

    public void setRecommendType(Byte recommendType) {
        this.recommendType = recommendType;
    }
    
    

    @Override
    public String toString() {
        return "GoodsRecommendModel [id=" + id + ", goodsId=" + goodsId + ", startDate="
               + startDate + ", endDate=" + endDate + ", recommendStatus=" + recommendStatus
               + ", recommendOrder=" + recommendOrder + ", createdDate=" + createdDate
               + ", createdName=" + createdName + ", updatedDate=" + updatedDate + ", updatedName="
               + updatedName + "]";
    }

}
